@ibiz-template-plugin/ibiz-file-previewer 0.0.26 → 0.0.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -942,6 +942,10 @@ var FileType = /* @__PURE__ */ ((FileType2) => {
942
942
  FileType2["JPEG"] = "jpeg";
943
943
  FileType2["ICO"] = "ico";
944
944
  FileType2["CSV"] = "csv";
945
+ FileType2["VUE"] = "vue";
946
+ FileType2["TSV"] = "tsv";
947
+ FileType2["MP4"] = "mp4";
948
+ FileType2["PHP"] = "php";
945
949
  FileType2["UNKNOWN"] = "UNKNOWN";
946
950
  return FileType2;
947
951
  })(FileType || {});
@@ -1006,6 +1010,21 @@ const FileTypeEngineMap = /* @__PURE__ */ new Map([
1006
1010
  /* TXT */
1007
1011
  ]],
1008
1012
  // XML类型文件
1013
+ ["vue", [
1014
+ "TXT"
1015
+ /* TXT */
1016
+ ]],
1017
+ // VUE类型文件
1018
+ ["tsv", [
1019
+ "TXT"
1020
+ /* TXT */
1021
+ ]],
1022
+ // TSV类型文件
1023
+ ["php", [
1024
+ "TXT"
1025
+ /* TXT */
1026
+ ]],
1027
+ // PHP类型文件
1009
1028
  // [FileType.TXT, [EngineType.TXT]], // TXT类型文件
1010
1029
  ["txt", [
1011
1030
  "MD"
@@ -1089,8 +1108,13 @@ const FileTypeEngineMap = /* @__PURE__ */ new Map([
1089
1108
  ["ico", [
1090
1109
  "IMG"
1091
1110
  /* IMG */
1092
- ]]
1111
+ ]],
1093
1112
  // ICO类型文件
1113
+ ["mp4", [
1114
+ "IMG"
1115
+ /* IMG */
1116
+ ]]
1117
+ // MP4类型文件
1094
1118
  ]);
1095
1119
  const contentWidth = 800;
1096
1120
  const imgModes = [
@@ -1173,6 +1197,9 @@ const fileNameToFileType = (fileName) => {
1173
1197
  case "svg":
1174
1198
  fileType = FileType.SVG;
1175
1199
  break;
1200
+ case "mp4":
1201
+ fileType = FileType.MP4;
1202
+ break;
1176
1203
  case "bmp":
1177
1204
  fileType = FileType.BMP;
1178
1205
  break;
@@ -1194,6 +1221,15 @@ const fileNameToFileType = (fileName) => {
1194
1221
  case "yml":
1195
1222
  fileType = FileType.YML;
1196
1223
  break;
1224
+ case "vue":
1225
+ fileType = FileType.VUE;
1226
+ break;
1227
+ case "tsv":
1228
+ fileType = FileType.TSV;
1229
+ break;
1230
+ case "php":
1231
+ fileType = FileType.PHP;
1232
+ break;
1197
1233
  default:
1198
1234
  fileType = FileType.UNKNOWN;
1199
1235
  }
@@ -1257,6 +1293,9 @@ const copyTextToClipboard = async (text) => {
1257
1293
  return fallbackCopyTextToClipboard(text);
1258
1294
  }
1259
1295
  };
1296
+ const isObject = (obj) => {
1297
+ return toString.call(obj) === "[object Object]";
1298
+ };
1260
1299
  var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
1261
1300
  function getDefaultExportFromCjs(x2) {
1262
1301
  return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2;
@@ -2284,18 +2323,38 @@ const FilePreviewImage = (props) => {
2284
2323
  if (controller.state.value.fileType === FileType.SVG)
2285
2324
  props.onInitialization();
2286
2325
  }, []);
2287
- return /* @__PURE__ */ u("div", { className: "file-preview-image ".concat(controller.state.value.theme), children: [
2288
- controller.state.value.fileType === FileType.SVG ? /* @__PURE__ */ u(
2289
- "div",
2290
- {
2291
- className: "svg-container",
2292
- style: imgStyle.value,
2293
- dangerouslySetInnerHTML: {
2294
- __html: controller.state.value.content
2295
- },
2296
- onMouseDown: (evt) => controller.handleMouseDown(evt)
2297
- }
2298
- ) : /* @__PURE__ */ u(
2326
+ const renderContent = () => {
2327
+ if (controller.state.value.fileType === FileType.SVG) {
2328
+ return /* @__PURE__ */ u(
2329
+ "div",
2330
+ {
2331
+ className: "svg-container",
2332
+ style: imgStyle.value,
2333
+ dangerouslySetInnerHTML: {
2334
+ __html: controller.state.value.content
2335
+ },
2336
+ onMouseDown: (evt) => controller.handleMouseDown(evt)
2337
+ }
2338
+ );
2339
+ }
2340
+ if (controller.state.value.fileType === FileType.MP4) {
2341
+ return /* @__PURE__ */ u(
2342
+ "video",
2343
+ {
2344
+ controls: true,
2345
+ onLoadedData: () => props.onInitialization(),
2346
+ onError: () => props.onInitialization(),
2347
+ children: /* @__PURE__ */ u(
2348
+ "source",
2349
+ {
2350
+ src: controller.state.value.content,
2351
+ type: "video/mp4"
2352
+ }
2353
+ )
2354
+ }
2355
+ );
2356
+ }
2357
+ return /* @__PURE__ */ u(
2299
2358
  "img",
2300
2359
  {
2301
2360
  style: imgStyle.value,
@@ -2304,7 +2363,10 @@ const FilePreviewImage = (props) => {
2304
2363
  onError: () => props.onInitialization(),
2305
2364
  onMouseDown: (evt) => controller.handleMouseDown(evt)
2306
2365
  }
2307
- ),
2366
+ );
2367
+ };
2368
+ return /* @__PURE__ */ u("div", { className: "file-preview-image ".concat(controller.state.value.theme), children: [
2369
+ renderContent(),
2308
2370
  /* @__PURE__ */ u(Teleport, { to: "#".concat(controller.controlsId), children: /* @__PURE__ */ u("div", { className: "image-toolbar-container", children: [
2309
2371
  /* @__PURE__ */ u(
2310
2372
  "button",
@@ -19014,7 +19076,12 @@ const FilePreviewText = (props) => {
19014
19076
  try {
19015
19077
  if (c2.state.value.fileType === FileType.JSON) {
19016
19078
  try {
19017
- const jsonObject = JSON.parse(c2.state.value.content);
19079
+ let jsonObject;
19080
+ if (isObject(c2.state.value.content) || Array.isArray(c2.state.value.content)) {
19081
+ jsonObject = c2.state.value.content;
19082
+ } else {
19083
+ jsonObject = JSON.parse(c2.state.value.content);
19084
+ }
19018
19085
  previewRef.current.textContent = JSON.stringify(jsonObject, null, 2);
19019
19086
  } catch (error2) {
19020
19087
  previewRef.current.textContent = c2.state.value.content;